package com.tian.arch.widget

import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import com.tian.arch.R
import com.tian.arch.databinding.DLoadingDialogBinding

/**
 * 加载中转圈的弹窗
 */
class LoadingDialog private constructor(context: Context, theme: Int) : Dialog(context, theme) {
    init {
        val binding = DLoadingDialogBinding.inflate(LayoutInflater.from(context))
        setContentView(binding.root)
        setCancelable(true)
        setCanceledOnTouchOutside(false)
        window?.apply {
            attributes.gravity = Gravity.CENTER
            val lp = attributes
            lp.dimAmount = 0.5f
            attributes = lp
        }
    }

    companion object {
        fun create(context: Context): LoadingDialog {
            return LoadingDialog(context, R.style.LightProgressDialog)
        }
    }
}